package com.itheima.home_work.test5;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class Test {
    public static void main(String[] args) {
        /**
         * 1. 定义LinkedHashMap对象，键是学生对象，值是地址
         * 2. 创建学生对象存入数据
         * 3. 遍历查看结果
         */

        LinkedHashMap students = new LinkedHashMap<Student, String>();

        students.put(new Student(1, "小明", 80), "住在哪呢？");
        students.put(new Student(2, "小曾", 70), "住在哪呢？3号");
        students.put(new Student(3, "小红", 20), "住在哪呢？5号病房");
        students.put(new Student(1, "小明", 80), "住在哪呢？药不能停");

        students.forEach((Object k, Object v) -> {
//            String str = k.getName() + "学号是：" + k.getId() + " --> 住在：" + v;
            Student key = (Student) k;
            String value = (String) v;
            System.out.println(key.getName() + "学号是：" + key.getId() + " --> 住在：" + v);
        });

    }
}
